Introspective Sorting and Selection Algorithms
نویسنده
چکیده
Quicksort is the preferred in-place sorting algorithm in many contexts, since its average computing time on uniformly distributed inputs is (N log N) and it is in fact faster than most other sorting algorithms on most inputs. Its drawback is that its worst-case time bound is (N 2). Previous attempts to protect against the worst case by improving the way quicksort chooses pivot elements for partitioning have increased the average computing time too much|one might as well use heapsort, which has a (N log N) worst-case time bound but is on the average 2 to 5 times slower than quicksort. A similar dilemma exists with selection algorithms (for nding the i-th largest element) based on partitioning. This paper describes a simple solution to this dilemma: limit the depth of partitioning, and for subproblems that exceed the limit switch to another algorithm with a better worst-case bound. Using heapsort as the \stopper" yields a sorting algorithm that is just as fast as quicksort in the average case but also has an (N log N) worst case time bound. For selection, a hybrid of Hoare's find algorithm, which is linear on average but quadratic in the worst case, and the Blum-Floyd-Pratt-Rivest-Tarjan algorithm is as fast as Hoare's algorithm in practice, yet has a linear worst-case time bound. Also discussed are issues of implementing the new algorithms as generic algorithms and accurately measuring their performance in the framework of the C++ Standard Template Library.
منابع مشابه
Data from Introspective Reports: Upgrading from Commonsense to Science
Introspective reports are used as sources of information about other minds, in both everyday life and science. Many scientists and philosophers consider this practice unjustified, while others have made the untestable assumption that introspection is a truthful method of private observation. I argue that neither skepticism nor faith concerning introspective reports are warranted. As an alternat...
متن کاملAn Enhancement of Major Sorting Algorithms
One of the fundamental issues in computer science is ordering a list of items. Although there is a huge number of sorting algorithms, sorting problem has attracted a great deal of research; because efficient sorting is important to optimize the use of other algorithms. This paper presents two new sorting algorithms, enhanced selection sort and enhanced bubble Sort algorithms. Enhanced selection...
متن کاملSorting - Based Selection
This paper presents several deterministic algorithms for selecting the kth largest record from a set of n records on any n-node hypercubic network. All of the algorithms are based on the selection algorithm of Cole and Yap, as well as on various sorting algorithms for hypercubic networks. Our fastest algorithm runs in O(lg n lg n) time, very nearly matching the trivial (lg n) lower bound. Previ...
متن کاملSorting and Selection on Distributed Memory Bus Computers
In this paper we study the problems of sorting and selection on the Distributed Memory Bus Computer (DMBC) recently introduced by Sahni. In particular we present: 1) An efficient algorithm for computing the sum of n bits; 2) An optimal O(1) time sorting algorithm; 3) An optimal randomized logarithmic time integer sorting algorithm; and 4) An optimal randomized constant time selection algorithm....
متن کاملRandom Sampling: Sorting and Selection
Random sampling techniques have played a vital role in the design of sorting and selection algorithms for numerous models of computing. In this article we provide a summary of sorting and selection algorithms that have been devised using random sampling. Models of computations treated include the parallel comparison tree, the PRAM, the mesh, the mesh with fixed, reconfigurable, and optical buse...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Softw., Pract. Exper.
دوره 27 شماره
صفحات -
تاریخ انتشار 1997